<template>
  <h1>我是子组件SubLocal</h1>
  <h1>获取父组件传递的参数：{{content}}</h1>
  <h3>{{res}}</h3>
<!--  <button @click="update()">修改content数据</button>-->
  <button @click="seed">子组件相父组件发送数据</button>

  <SubSubLocal/>
</template>

<script>
  import SubSubLocal from "@/components/SubSublocal"
  export default {
    name: "SubLocal",
    components: {
      SubSubLocal
    },
    //1.子组件侧用props定义接收参数列表
    props: {
      content: {
        require: true, // 此参数必须传递
        type: Number
      },
      res: {
        require: false,
        type: String
      }
    },
    methods: {
      update(){
        this.content = "数据被修改了";
      },
      seed(){
        // alert("seed方法");
        // 通过事件方式将数据传递到父组件
        this.$emit("subRes", "大漠孤烟直，长河落日圆")
      }
    }
  }
</script>

<style scoped>

</style>